package com.wk.jetpackdemo.utils

import android.os.Handler
import android.os.Looper

object CommonUtils {
    private val sHandler = Handler()
    fun runOnUiThread(runnable: Runnable) {
        if (checkMainThread()) {
            runnable.run()
            return
        }
        sHandler.post(runnable)
    }

    private fun checkMainThread(): Boolean {
        return (Looper.myLooper() == Looper.getMainLooper())
    }
}